# Maintainer: Anatol Pomozov <anatol.pomozov@gmail.com>
# Contributor: Massimiliano Torromeo <massimiliano.torromeo at gmail dot com>
# Contributor: Alexsandr Pavlov <kidoz at mail dot ru>
# Contributor: Andreas 'Segaja' Schleifer <segaja at archlinux dot org>

_gemname=rdiscount
pkgname=ruby-$_gemname
pkgver=2.2.7.1
pkgrel=1
pkgdesc="Fast Implementation of Gruber's Markdown in C"
arch=(loong64 x86_64)
url='https://dafoster.net/projects/rdiscount/'
license=(BSD)
depends=(ruby)
makedepends=('ruby-rdoc')
options=(!emptydirs)
source=(https://rubygems.org/downloads/$_gemname-$pkgver.gem)
noextract=($_gemname-$pkgver.gem)
sha256sums=('51ab13ce8781c813c88a191eb7d5704ebde2a5d2417cf0e01fd46997748330a9')

package() {
  local _gemdir="$(ruby -e'puts Gem.default_dir')"
  local _platform="$(gem env platform | cut -d':' -f2)"
  local _extension_api_version="$(ruby -e'puts Gem.extension_api_version')"
  gem install --ignore-dependencies --no-user-install -i "$pkgdir/$_gemdir" -n "$pkgdir/usr/bin" $_gemname-$pkgver.gem
  rm "$pkgdir/$_gemdir/cache/$_gemname-$pkgver.gem" \
      "${pkgdir}/${_gemdir}/extensions/${_platform}/${_extension_api_version}/${_gemname}-${pkgver}/gem_make.out"
  install -D -m644 "$pkgdir/$_gemdir/gems/$_gemname-$pkgver/COPYING" "$pkgdir/usr/share/licenses/$pkgname/COPYING"

  rm -rf "$pkgdir/$_gemdir/gems/$_gemname-$pkgver/ext" \
      "${pkgdir}/${_gemdir}/doc/${_gemname}-${pkgver}/ri/ext"
}
